namespace Jumpton.SFA.Server.Entity {
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Jumpton.Persistent;
    using System.Data;
    using System.Runtime.Serialization;
    
    
    [System.SerializableAttribute()]
    [Map("PAY_TERMS")]
    public class PAY_TERMS : ObjectRow {
        
        public PAY_TERMS() {
        }
        
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dataRow">DataTable 中的一行数据</param>
        /// <param name="objectTable">存储当前对象的数据表格</param>
        public PAY_TERMS(System.Data.DataRow dataRow, ObjectTable parent) : 
                base(dataRow, parent) {
        }
        
        /// <summary>
        /// 供反序列化使用的构造函数
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected PAY_TERMS(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : 
                base(info, context) {
        }
        
        [Key("ID",true,true)]
        public decimal ID {
            get {
                return (System.Decimal)GetValue("ID");
            }
            set {
                SetValue("ID", value);
            }
        }
        
        [Field("SAP_CODE")]
        public string SAPCODE {
            get {
                return (System.String)GetValue("SAPCODE");
            }
            set {
                SetValue("SAPCODE", value);
            }
        }
        
        [Field("DESCRIPTION")]
        public string DESCRIPTION {
            get {
                return (System.String)GetValue("DESCRIPTION");
            }
            set {
                SetValue("DESCRIPTION", value);
            }
        }
        
        [Field("TYPE")]
        public int TYPE {
            get {
                return (int)GetValue("TYPE");
            }
            set {
                SetValue("TYPE", value);
            }
        }

        /// <summary>
        /// 类型名称
        /// </summary>
        [CalculateField]
        public string TypeName
        {
            get
            {
                DictionaryItems item = ((DictionaryItems)ObjectRow.Load(typeof(DictionaryItems), "dictionaryitemid=" + TYPE.ToString()));
                if (item != null)
                    return item.Name;
                return null;
            }
            
        }
        
        [Field("PERCENTS")]
        public decimal PERCENT {
            get {
                return (System.Decimal)GetValue("PERCENT");
            }
            set {
                SetValue("PERCENT", value);
            }
        }
        
        [Field("DUE_DAYS")]
        public decimal DUEDAYS {
            get {
                return (System.Decimal)GetValue("DUEDAYS");
            }
            set {
                SetValue("DUEDAYS", value);
            }
        }
        
       
        
        [Field("DOMAIN_ID")]
        public decimal DOMAINID {
            get {
                return (System.Decimal)GetValue("DOMAINID");
            }
            set {
                SetValue("DOMAINID", value);
            }
        }

        [Field("LAST_UPDATER")]
        public string LAST_UPDATER
        {
            get
            {
                return (System.String)GetValue("LAST_UPDATER");
            }
            set
            {
                SetValue("LAST_UPDATER", value);
            }
        }

        [Field("LAST_UPDATE_TIME")]
        public decimal LAST_UPDATE_TIME
        {
            get
            {
                return (decimal)GetValue("LAST_UPDATE_TIME", DateTime.Now);
            }
            set
            {
                SetValue("LAST_UPDATE_TIME", value);
            }
        }

        [Field("CREATE_TIME")]
        public long CREATETIME
        {
            get
            {
                return (long)GetValue("CREATETIME", DateTime.Now);
            }
            set
            {
                SetValue("CREATETIME", value);
            }
        }

        [Field("ACTIVE")]
        public Boolean ACTIVE
        {
            get
            {
                return (System.Boolean)GetValue("ACTIVE", false);
            }
            set
            {
                SetValue("ACTIVE", value);
            }
        }
        [Field("PAY_TERM_GROUP_ID")]
        public decimal PAYTERMGROUPID {
            get {
                return (System.Decimal)GetValue("PAYTERMGROUPID");
            }
            set {
                SetValue("PAYTERMGROUPID", value);
            }
        }


        [CalculateField]
        public string TYPENAME
        {
            get
            {
                return GetTypeName(GetValue("TYPE").ToString());
            }
        }

        private string GetTypeName(string type)
        {
            switch (type)
            {
                case "0":
                    return "现金";
                case "1":
                    return "支票";
                case "2":
                    return "银行转帐";
                case "3":
                    return "汇款";
                case "4":
                    return "PDC";
                default:
                    return "";

            }
        }
    }
}
